

import com.sun.midp.io.ResourceInputStream;
import com.sun.midp.lcdui.Resource;
import gene.core.Core;
import gene.core.sound.SoundPlayer;
//import game.demoScreen;
import java.io.IOException;
import java.io.InputStream;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
//import javax.microedition.

public class Main extends MIDlet {
    
    private Core coreInstance;

    private static InputStream resource;

    private Display d;

    static private Display dip;

    //static Graphics g;
   
    //private static final int W_H [ ] = { Core.getInstance().getWidth() , Core.getInstance().getHeight() };
    
    //private static final int H = 172;

    public void pauseApp() {
        if(coreInstance!=null){
            coreInstance.pause();
        }else{startApp();}
    }

    public void destroyApp(boolean unconditional) {
        if( unconditional ){
        
        dip.setCurrent(null);
        Core.graphics = null;
        dip = null;
         //desaloca todo o jogo e chama o Coletor de lixo
        coreInstance.exit();
         
        }
       }
    
    public void startApp() {
    Core tmp;
      if(coreInstance == null){
      try{

       Core.InitEngine( 0,0, false);
       coreInstance = Core.getInstance();
       dip = Display.getDisplay( this );
       Core.graphics = coreInstance.getCoreGraphics( );

       dip.setCurrent( coreInstance );

       coreInstance.setScreen(new demoScreen());
      
       coreInstance.run( );

       destroyApp( true );

      }catch(Exception e){e.printStackTrace();}
        }
    }
}